home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
vhf
/
locator
/
locowl.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-29
|
6KB
|
231 lines
//REGEN_FILEHEADING
#include <stdio.h>
//REGEN_FILEHEADING
/********************************************************************
* *
* Source File: LOCOWL.cpp *
* Description: C++ Source file for LOCOWL application *
* Date: Sun Nov 29 18:09:13 1992 *
* *
********************************************************************/
#include <owl.h>
#include <edit.h>
#include <listbox.h>
#include <combobox.h>
#include <scrollba.h>
#include <dialog.h>
#include "LOCDLG.H"
#include "LOCOWLID.h"
#include "LOCOWL.h"
#include "LOCOWCls.h"
//REGEN_VARIABLES
//REGEN_VARIABLES
// Define application class derived from TApplication
class TLOCOWL : public TApplication
{
public:
TLOCOWL(LPSTR AName, HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
: TApplication(AName, hInstance, hPrevInstance, lpCmdLine, nCmdShow) {};
virtual void InitMainWindow();
//REGEN_APPCLASS
//REGEN_APPCLASS
};
// Declare TMainWindow, a TDialog descendant
class TMainWindow : public TDialog
{
public:
TMainWindow(PTWindowsObject AParent, LPSTR ATitle);
~TMainWindow();
PTEdit Editfromloc;
PTEdit Edittoloc;
virtual void TMainWindowidcalc(RTMessage Msg) = [ID_FIRST + idcalc];
virtual void Cancel(RTMessage Msg) = [ID_FIRST + IDCANCEL];
virtual void ABOUT(RTMessage Msg) = [CM_FIRST + IDM_ABOUT];
//REGEN_MAINCLASS
PTStatic Sfromstat;
PTStatic Stostat;
PTStatic Sdist;
PTStatic Sdir;
//REGEN_MAINCLASS
protected:
virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
virtual LPSTR GetClassName();
virtual void SetupWindow();
};
/****************************************************
* TMainWindow implementations:
****************************************************/
// Define TMainWindow, a TWindow constructor
TMainWindow::TMainWindow(PTWindowsObject AParent, LPSTR ATitle)
: TDialog(AParent, ATitle)
{
Editfromloc = new TEdit(this, fromloc, 0);
Edittoloc = new TEdit(this, toloc, 0);
//REGEN_MAINCONSTRUCT
Sdist = new TStatic(this, dist, 0);
Sdir = new TStatic(this, dir, 0);
Sfromstat = new TStatic(this, fromstat, 0);
Stostat = new TStatic(this, tostat, 0);
//REGEN_MAINCONSTRUCT
}
// Define TMainWindow destructor
TMainWindow::~TMainWindow()
{
//REGEN_MAINDESTRUCT
delete Sdist;
delete Sdir;
delete Sfromstat;
delete Stostat;
//REGEN_MAINDESTRUCT
delete Editfromloc;
delete Edittoloc;
}
void TMainWindow::SetupWindow()
{
TDialog::SetupWindow();
SetMenu(HWindow, LoadMenu(GetWindowWord(HWindow, GWW_HINSTANCE), "LOCOWL"));
// not preserved during Protogen generation !
// append to module TMainWindow::SetupWindow() code
const int MAXLOC = 6+1;
char def_from[MAXLOC];
GetProfileString ("locator", "fromdefault", "", def_from, MAXLOC);
Editfromloc->SetText(def_from);
// end of not preserved....
}
LPSTR TMainWindow::GetClassName()
{
return "MainWindow";
}
void TMainWindow::GetWindowClass(WNDCLASS _FAR & AWndClass)
{
TDialog::GetWindowClass(AWndClass);
AWndClass.hIcon = LoadIcon(AWndClass.hInstance, "LOCATOR");
AWndClass.lpszMenuName = (LPSTR)"LOCOWL";
//REGEN_CLASSINFO
//REGEN_CLASSINFO
}
void TMainWindow::TMainWindowidcalc(RTMessage Msg)
{
switch(Msg.LP.Hi)
{
case BN_CLICKED :
//REGEN_TMainWindowidcalc_ROUTING
double distance, bearing;
const int MAXLOC = 6+1;
char from[MAXLOC], to[MAXLOC], buffer[10];
int locstat;
Editfromloc->GetText(from, MAXLOC);
Edittoloc->GetText(to, MAXLOC);
locstat = locs_to_bearing (from, to, &distance, &bearing);
Stostat->SetText(to);
Sfromstat->SetText(from);
if (locstat) { //at least either locator not ok
Sdir->SetText("");
Sdist->SetText("");
if (locstat & 2)
Stostat->SetText("Invalid");
if (locstat & 1)
Sfromstat->SetText("Invalid");
} else { //both ok
sprintf (buffer, "%5.0lf", distance + 0.5);
Sdist->SetText(buffer);
sprintf (buffer, "%5.0lf", bearing + 0.5);
Sdir->SetText(buffer);
}
//REGEN_TMainWindowidcalc_ROUTING
break;
}
}
void TMainWindow::Cancel(RTMessage Msg)
{
switch(Msg.LP.Hi)
{
case BN_CLICKED :
//REGEN_TMainWindowIDCANCEL_ROUTING
//REGEN_TMainWindowIDCANCEL_ROUTING
TDialog::Cancel(Msg);
}
}
void TMainWindow::ABOUT(RTMessage)
{
// Execute modal dialog
if (GetModule()->ExecDialog(
new TabtdlgDlg(this, "abtdlg")) == IDOK )
{
//REGEN_ABOUT_EXEC
//REGEN_ABOUT_EXEC
}
}
/***************************************************
* TLOCOWLApp method implementations:
***************************************************/
// Construct the TLOCOWL's MainWindow of type TMainWindow
void TLOCOWL::InitMainWindow()
{
MainWindow = new TMainWindow(NULL, "locdlg");
//REGEN_MAINCREATE
//REGEN_MAINCREATE
}
// Main program
int PASCAL WinMain(HANDLE hInstance,
HANDLE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
//REGEN_INIT
//REGEN_INIT
TLOCOWL LOCOWL ("Locator Calculator by OH3NJC", hInstance, hPrevInstance,
lpCmdLine, nCmdShow);
LOCOWL.Run();
//REGEN_CLEANUP
//REGEN_CLEANUP
return LOCOWL.Status;
}
//REGEN_CUSTOMCODE
/*
// not preserved during Protogen generation !
// append to module TMainWindow::SetupWindow() code
const int MAXLOC = 6+1;
char def_from[MAXLOC];
GetProfileString ("locator", "fromdefault", "", def_from, MAXLOC);
Editfromloc->SetText(def_from);
// end of not preserved....
*/
//REGEN_CUSTOMCODE